public class text1 {
    public static void main1(String[] args) {
        Dog dog = new Dog("旺仔",10,"灰色");
        dog.barks();
        dog.eat();
    }
    public static void main2(String[] args) {
        Animal animal = new Dog("旺仔",10,"灰色");
        animal.eat();
    }
public static void fun(Animal animal){
        animal.eat();
}
    public static void main3(String[] args) {
        Dog dog =  new Dog("旺仔",10,"灰色");
        fun(dog);
        Bird bird = new Bird("布谷",3);
        fun(bird);
    }

    public static void main(String[] args) {
        Animal animal1 = new Bird("布谷",3);
        if(animal1 instanceof Bird){
        Bird bird1=(Bird)animal1;
        bird1.fly();
        String []arr={"sdfv","sdvss"};

        }
    }
}
class Animal{
    public String name;
    public int age;
    public void eat(){
        System.out.println(this.name+"正在吃");
    }
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
}
class Dog extends Animal{
    public String color;
    public Dog(String name, int age,String color) {
        super(name, age);
        this.color=color;
    }
    public void barks(){
    System.out.println("正在狗叫");
}
    public void eat(){
        System.out.println(this.name+"正在狗粮");
    }
}
class Bird extends Animal{
    public Bird(String name, int age) {
        super(name, age);
    }
    public void fly(){
        System.out.println("正在飞翔");
    }
    @Override
    public void eat(){
        System.out.println("正在吃鸟粮");
    }
}
